// 2025/10/17
// 区间汇总

class Solution {
public:
    vector<string> summaryRanges(vector<int>& nums) {
        sort(nums.begin(), nums.end());
        vector<string> ans;
        if(nums.empty())
            return ans;
        int left = nums[0], n = nums.size();
        for(int i = 1; i <= n; i++)
        {
            if(i == n || nums[i] != nums[i - 1] + 1)
            {
                string tmp;
                if(left != nums[i - 1])
                    tmp = to_string(left) + "->" + to_string(nums[i - 1]);
                else
                    tmp = to_string(left);
                ans.push_back(tmp);
                if(i < n)
                    left = nums[i];
            }
        }
        return ans;
    }
};